.class Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;
.super Ljava/lang/Object;
.source "RequestBalanceResetRunnable.java"

# interfaces
.implements Ljava/lang/Runnable;


# static fields
.field static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field static final MS_IN_SEC:I = 0x3e8

.field static final TAG:Ljava/lang/String;


# instance fields
.field private final mListeners:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Lcom/burstly/lib/feature/currency/ICurrencyListener;",
            ">;"
        }
    .end annotation
.end field

.field final mNewAccountInfo:Lcom/burstly/lib/currency/AccountInfo;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 39
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->LOG:Lcom/burstly/lib/util/LoggerExt;

    .line 44
    const-class v0, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->TAG:Ljava/lang/String;

    return-void
.end method

.method constructor <init>(Lcom/burstly/lib/currency/AccountInfo;Ljava/util/List;)V
    .locals 0
    .parameter "newAccountInfo"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lcom/burstly/lib/currency/AccountInfo;",
            "Ljava/util/List",
            "<",
            "Lcom/burstly/lib/feature/currency/ICurrencyListener;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 87
    .local p2, listeners:Ljava/util/List;,"Ljava/util/List<Lcom/burstly/lib/feature/currency/ICurrencyListener;>;"
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 88
    iput-object p1, p0, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->mNewAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    .line 89
    iput-object p2, p0, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->mListeners:Ljava/util/List;

    .line 90
    return-void
.end method

.method private notifyListeners(Ljava/util/Map;Z)V
    .locals 9
    .parameter
    .parameter "succeeded"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Lcom/burstly/lib/currency/BalanceUpdateInfo;",
            ">;Z)V"
        }
    .end annotation

    .prologue
    .line 174
    .local p1, event:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Lcom/burstly/lib/currency/BalanceUpdateInfo;>;"
    iget-object v3, p0, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->mListeners:Ljava/util/List;

    invoke-interface {v3}, Ljava/util/List;->isEmpty()Z

    move-result v3

    if-nez v3, :cond_0

    .line 176
    :try_start_0
    iget-object v3, p0, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->mListeners:Ljava/util/List;

    invoke-interface {v3}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v1

    .local v1, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_0

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/burstly/lib/feature/currency/ICurrencyListener;

    .line 177
    .local v2, listener:Lcom/burstly/lib/feature/currency/ICurrencyListener;
    if-nez p2, :cond_1

    .line 178
    invoke-interface {v2, p1}, Lcom/burstly/lib/feature/currency/ICurrencyListener;->didFailToUpdateBalance(Ljava/util/Map;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 184
    .end local v1           #i$:Ljava/util/Iterator;
    .end local v2           #listener:Lcom/burstly/lib/feature/currency/ICurrencyListener;
    :catch_0
    move-exception v0

    .line 185
    .local v0, exception:Ljava/lang/Exception;
    sget-object v3, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->LOG:Lcom/burstly/lib/util/LoggerExt;

    sget-object v4, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->TAG:Ljava/lang/String;

    const-string v5, "Uncaught Exception occured in currency listener: {0}"

    const/4 v6, 0x1

    new-array v6, v6, [Ljava/lang/Object;

    const/4 v7, 0x0

    invoke-virtual {v0}, Ljava/lang/Exception;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v8

    aput-object v8, v6, v7

    invoke-virtual {v3, v4, v5, v6}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 189
    .end local v0           #exception:Ljava/lang/Exception;
    :cond_0
    return-void

    .line 180
    .restart local v1       #i$:Ljava/util/Iterator;
    .restart local v2       #listener:Lcom/burstly/lib/feature/currency/ICurrencyListener;
    :cond_1
    :try_start_1
    invoke-interface {v2, p1}, Lcom/burstly/lib/feature/currency/ICurrencyListener;->didUpdateBalance(Ljava/util/Map;)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0
.end method

.method private prepareRequest(Lcom/burstly/lib/currency/AccountInfo;)Lcom/burstly/lib/currency/request/ResetAccountBalance;
    .locals 6
    .parameter "info"

    .prologue
    .line 161
    new-instance v0, Lcom/burstly/lib/currency/request/ResetAccountBalance;

    invoke-direct {v0}, Lcom/burstly/lib/currency/request/ResetAccountBalance;-><init>()V

    .line 162
    .local v0, updateRequest:Lcom/burstly/lib/currency/request/ResetAccountBalance;
    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getPubId()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcom/burstly/lib/currency/request/ResetAccountBalance;->setPublisher(Ljava/lang/String;)V

    .line 163
    sget-object v1, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->LOG:Lcom/burstly/lib/util/LoggerExt;

    sget-object v2, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->TAG:Ljava/lang/String;

    const-string v3, "Reset balance object is: {0}"

    const/4 v4, 0x1

    new-array v4, v4, [Ljava/lang/Object;

    const/4 v5, 0x0

    aput-object v0, v4, v5

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 164
    return-object v0
.end method


# virtual methods
.method notifyReset(Z)V
    .locals 1
    .parameter "success"

    .prologue
    .line 203
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    invoke-direct {p0, v0, p1}, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->notifyListeners(Ljava/util/Map;Z)V

    .line 204
    return-void
.end method

.method protected onResetFinished()V
    .locals 0

    .prologue
    .line 195
    return-void
.end method

.method public run()V
    .locals 4

    .prologue
    .line 94
    iget-object v2, p0, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->mNewAccountInfo:Lcom/burstly/lib/currency/AccountInfo;

    invoke-direct {p0, v2}, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;->prepareRequest(Lcom/burstly/lib/currency/AccountInfo;)Lcom/burstly/lib/currency/request/ResetAccountBalance;

    move-result-object v1

    .line 95
    .local v1, updateRequest:Lcom/burstly/lib/currency/request/ResetAccountBalance;
    new-instance v2, Lcom/burstly/lib/currency/secured/SecuredRequestBuilder;

    invoke-direct {v2}, Lcom/burstly/lib/currency/secured/SecuredRequestBuilder;-><init>()V

    invoke-virtual {v2, v1}, Lcom/burstly/lib/currency/secured/SecuredRequestBuilder;->setData(Ljava/lang/Object;)Lcom/burstly/lib/currency/secured/SecuredRequestBuilder;

    move-result-object v2

    invoke-virtual {v2}, Lcom/burstly/lib/currency/secured/SecuredRequestBuilder;->buildResetAccountRequest()Lcom/burstly/lib/currency/secured/SecuredServiceRequest;

    move-result-object v0

    .line 96
    .local v0, toPOst:Lcom/burstly/lib/currency/secured/SecuredServiceRequest;
    new-instance v2, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable$1;

    const-class v3, Lcom/burstly/lib/currency/request/AccountBalanceChangeResponse;

    invoke-direct {v2, p0, v0, v3}, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable$1;-><init>(Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable;Ljava/lang/Object;Ljava/lang/Class;)V

    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Void;

    invoke-virtual {v2, v3}, Lcom/burstly/lib/currency/request/RequestBalanceResetRunnable$1;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;

    .line 138
    return-void
.end method
